package com.skycode7.servlet;

import com.skycode7.bean.NewsBean;
import com.skycode7.dao.NewsDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsdetail.html")
public class NewsDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws SecurityException, IOException, ServletException {
        String NewsId = req.getParameter("NewsId");
        int id = Integer.parseInt(NewsId);
        NewsBean news = (new NewsDao()).getOne(id);
        req.setAttribute("title", news.getNewsTime());
        req.setAttribute("content", news.getNewsContent());
        req.getRequestDispatcher("newsFrontDetail.jsp").forward(req, resp);
}
}
